package faas

import (
	"context"
	"flow-calc/core"
	"flow-calc/core/log"
	"fmt"
)

func FuncDemo1(ctx context.Context, flow core.Flow) error {
	log.Logger().InfoCtx(ctx, "---------------> %s <----------------", "第一个业务函数: FuncDemo1")

	for index, row := range flow.Input() {
		// 输出接收的参数数据
		log.Logger().Info("入参: funcName = %s, funcID=%s, 数据: %+v", flow.GetExecFuncConf().FName, flow.GetExecFunction().GetId(), row)
		// 计算结果数据进行提交
		resultStr := fmt.Sprintf("结果: funcName = %s, funcID=%s, index=%d", flow.GetExecFuncConf().FName, flow.GetExecFunction().GetId(), index)
		_ = flow.CommitRow(resultStr)
	}
	return nil
}
